﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;

namespace WBGDal
{
    public class Conexao
    {
        public static SqlConnection Get()
        {
            string connectionStr = ConfigurationManager.ConnectionStrings["WBGEntities"].ConnectionString;
            int pos1 = connectionStr.IndexOf("data source");
            int pos2 = connectionStr.IndexOf(";App");
            connectionStr = connectionStr.Substring(pos1, pos2 - pos1);
            SqlConnection conn = new SqlConnection(connectionStr);
            conn.Open();
            return conn;
        }

        //public static void Close(SqlConnection connection)
        //{
        //    if (connection.State == ConnectionState.Open)
        //        connection.Close();
        //}
    }
}
